package com.itboye.sunsun.adapter;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.sunsun.application.App;
import com.itboye.sunsun.beans.ProducenterDeleBean;
import com.itboye.sunsun.beans.ProducenterDeleBean.DeleteBeanProducer;
import com.itboye.sunsun.constants.NetPublicConstant;
import com.itboye.sunsun.utils.XImageLoader;
import com.itboye.sunsunhome.R;

public class ProductDetailAdapter extends BaseAdapter {

	List<DeleteBeanProducer> bean;

	public ProductDetailAdapter(
			List<DeleteBeanProducer> bean) {
		// TODO Auto-generated constructor stub
		this.bean = bean;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return bean == null ? 0 : bean.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {

			convertView = LayoutInflater.from(App.ctx).inflate(
					R.layout.item_producenter_chanpin, null);
			holder = new ViewHolder();
			holder.content = (TextView) convertView.findViewById(R.id.content);
			holder.time = (TextView) convertView.findViewById(R.id.time);
			holder.luntanTime = (TextView) convertView.findViewById(R.id.luntanTime);

			holder.iv1 = (ImageView) convertView.findViewById(R.id.iv1);

			holder.imgsContainer = (ViewGroup) convertView
					.findViewById(R.id.imgsContainer);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		DeleteBeanProducer list=bean.get(position);
		holder.content.setText(list.getPost_title());
		holder.luntanTime.setText("更新日期:");
		holder.time.setText(new SimpleDateFormat("yyyy年MM月dd日").format(Long
				.parseLong(list.getPost_date())*1000));
		XImageLoader.load(list.getMain_img(), holder.iv1);

		return convertView;
	}

	class ViewHolder {

		TextView content;
		TextView time;
		TextView luntanTime;
		ImageView iv1;
		ImageView luntanjing;

		ViewGroup imgsContainer;
	}
}
